package com.xiaoshuidi.cloud.module.member.repository;

import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.xiaoshuidi.cloud.module.member.controller.app.auth.vo.MemberAuthGetVerifyReqVO;
import com.xiaoshuidi.cloud.module.member.mapper.MemberAuthenticationMapper;
import com.xiaoshuidi.cloud.module.member.pojo.user.MemberAuthentication;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Repository;

@Repository
@RequiredArgsConstructor
public class MemberAuthenticationRepository extends ServiceImpl<MemberAuthenticationMapper, MemberAuthentication> {
    private final MemberAuthenticationMapper mapper;

    public MemberAuthentication getMemberAuthentication(MemberAuthGetVerifyReqVO reqVO) {
        return mapper.selectOne(new LambdaQueryWrapper<MemberAuthentication>()
                .eq(ObjectUtil.isNotEmpty(reqVO.getUserId()),MemberAuthentication::getUserId, reqVO.getUserId()));
    }

    public MemberAuthentication getMemberAuthenticationByCustomerId(String customerId) {
        return mapper.selectOne(new LambdaQueryWrapper<MemberAuthentication>()
                .eq(MemberAuthentication::getSignatureCode,customerId));
    }
}
